home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-06-28 | 44.5 KB | 1,197 lines | [TEXT/McSk] |
- ; this file is: Dictionary.txt -- forth words
- ; Tue Apr 05, 1988 21:59:10 load files >32K
- ; Thu Apr 07, 1988 15:59:46 nested loads
- ; Tue Apr 19, 1988 05:05:37 change "?BUTTON"
- ; Mon Apr 25, 1988 15:10:19 implement macros
- ; Tue Apr 26, 1988 19:49:49 optomizing "BACK"
- ; Thu Apr 28, 1988 23:09:23 fix ID. better CONSTANT,2CONSTANT add zero
- ; Fri Apr 29, 1988 09:43:49 add DLITERAL
- ; Sun May 01, 1988 04:24:52 make VARIABLE a macro
- ; Thu May 12, 1988 11:41:08 remove (PDO) add 1- 2- & SP@ use slashFail
- ; Sun May 29, 1988 20:16:39 make CREATE shorter
- ; Tue May 31, 1988 14:27:25 make +MD a 4 byte macro remove 2-
- ; Tue Jun 07, 1988 11:39:00 add R0@, S0@, RP@ redo STOD
- ; Sun Jun 23, 1991 09:33:00 add OPEN
- ; Thu Jan 13, 1992 19:05:00 Floating point math (rewrite 13Apr)
- ; Sun Feb 02, 1992 00:02:00 fix BACK
- ; Wed Apr 01, 1992 00:12:00 change STKCHK
- ; Tue Apr 14, 1992 22:48:00 rearrange to bring essentials toward front
- ; Sun Apr 19, 1992 23:24:00 split open into 2 parts, add AE: ;AE> ?GESTALT
- ; Sat Sep 19, 1992 17:05:00 fix FROLL in decimal places 15-19
- ; Fri Jan 22, 1993 19:28:00 fix TYPE
- ; Mon Apr 19, 1993 22:58:00 move ?BUTTON and FLITERAL
- ; Thu May 06, 1993 23:04:00 fix +LOOP and QUIT
- ; Sat May 29, 1993 15:20:00 fix TYPE (again)
- ; Tue Jun 01, 1993 23:25:00 add WARM, DEPTH
- ; Wed Jun 09, 1993 20:17:00 change IMMEDIATE,PAGE,doLoad,header,dictstart
-
- DictStart:
- DC.L 0 ; End of dictionary search
-
- DC.B 128+1,13,0,0 ; "{cr}" ( -- ) goto restart
- DC.W dictstart-base
- CRet: MOVE.L rzero-base(bp),rs ; reset return stack
- JMP Restart-base(BP) ; and jump
-
- DC.B 128+1,0,0,0 ; "{null}" ( -- ) same as cret
- DC.W cret-theLink
- NRet: BRA.S cret
-
- DC.B 128+1,'\',0,0 ; "\" ( -- ) backslash
- DC.W nret-theLink ; line ending comment
- Backsl: bra.s cret
-
- DC.B 9,'?TE' ; "?terminal" ( -- flag )
- DC.W backsl -theLink ; was a key pressed?
- QTerm: JSR NextEvent-base(BP)
- CLR -(PS)
- TST kflag-base(BP)
- BEQ.S @0
- SUBQ #1,(PS)
- @0: RTS
-
- DC.B 3,'KEY' ; "key" ( -- ascii )
- DC.W qterm-theLink ; wait for a key press
- Key: BSR.S Curs
- @0: JSR NextEvent-base(BP) ; set kflag if a key is pressed
- TST KFlag-base(BP) ; ( among other things... )
- BEQ.S @0
- BSR.S NoCurs
- MOVE KFlag-base(BP),-(PS)
- RTS
-
- NoCurs: MOVE #10,-(SP) ; SrcXor mode
- _PenMode
- Curs: clr.l -(sp)
- addq.l #6,(sp)
- _Move
- MOVE.L #$0000FFFA,-(SP) ; draw 6 pixels to the left
- _Line
- _PenNormal
- RTS
-
- DC.B 6,'?ST' ; "?stack" ( ? -- )
- DC.W key-theLink
- StkChk: CMPA.L Szero-base(BP),PS
- BGT.S @0
- RTS
- @0: JSR space-base(BP)
- MOVEQ #42,D0 ; print * if stack underflow
- JSR EmitCode-base(BP)
- BRA.S huh
-
- DC.B 7,'?BU' ; "?button" ( -- flag )
- DC.W StkChk-theLink
- QButton:
- CLR -(SP)
- _Button
- MOVE (SP)+,-(PS)
- BEQ.S @0
- SUBI #257,(PS)
- @0: RTS
-
- DC.B 6,'WHA' ; "whazat" ( -- )
- DC.W QButton-theLink
- WhaZat: jsr dwrd-base(bp) ; push token address
- BRA.S huh
-
- DC.B 5,'ABO' ; "abort" ( -- )
- DC.W whazat-theLink
- huh: MOVE.L Szero-base(BP),PS ; reset stack pointer < moved 5/93
- MOVEQ #63,D0 ; send ?
- JSR EmitCode-base(BP)
- BSR.S crlf
- BRA.S fin
-
- DC.B 4,'QUI' ; "quit" ( -- )
- DC.W huh-theLink ; restart the interpreter loop
- fin: JSR emptyfs-base(BP) ; clear pending loads
- CLR.L fcolon-base(BP) ; clear compiling flag
- BSET.B #7,fint-base(BP) ; reset to keyboard input
- JMP cret-base(BP)
-
- DC.B 2,'CR',0 ; "cr" ( -- ) output CR to screen
- DC.W fin-theLink
- CRLF: JMP doCR-Base(BP) ; part of emit
-
- DC.B 3,'.OK' ; ".ok" ( -- )
- DC.W crlf-theLink
- Prompt: JSR space-base(BP) ; send space
- MOVEQ #111,D0
- JSR EmitCode-base(BP) ; send "o"
- MOVEQ #107,D0
- JSR EmitCode-base(BP) ; send "k"
- JMP space-base(BP) ; send another space & return
-
- DC.B 5,'UPP' ; "upper" ( addr -- )
- DC.W prompt-theLink ; change a string to upper case
- Upper: MOVE (PS)+,D0
- LEA 0(BP,D0.W),A0 ; get the address
- CLR D0
- MOVE.B (A0),D0 ; get count
- @0: CMPI.B #$60,0(A0,D0.W) ; BEGIN get char at addr + count
- BLE.S @1 ; char > 'a'
- CMPI.B #$7B,0(A0,D0.W) ; char < 'z'
- BGE.S @1 ; AND IF
- SUBI.B #32,0(A0,D0.W) ; char 32 - -> char THEN
- @1: DBRA D0,@0 ; count 1- -> count count NOT UNTIL
- RTS
-
- DC.B 5,'TOK' ; "token" ( -- ) put a token
- DC.W upper-theLink ; from (IS) into (DP),
- Token: MOVE #32,-(PS) ; which is at end of dict.
- BSR.S word
- JSR here-base(BP) ; Fri Apr 29, 1988 00:27:23 simpl
- BRA.S Upper
-
- DC.B 6,'HEA' ; "header" ( -- ) create a header
- DC.W token-theLink ; for the current word at DP
- Header: MOVE Dict,4(DP) ; link header to dictionary
- MOVE.L DP,Dict ; update DICT
- SUB.L BP,Dict ; make it a rel.addr
- addq.l #6,dp ; update DP
- RTS
-
- DC.B vrefnum on stack ***
- CLR D0
- @0: MOVE.L 10(A2,D0.W),40(A2,D0.W) ; move the file name to PAD
- ADDQ #4,D0
- CMP #32,D0
- BLE.S @0
- ADDQ #1,openFlag-base(BP)
- RTS
-
- DC.B 3,'-->' ; "-->" ( -- )
- DC.W open-theLink
- Load: JSR token-base(BP) ; put filename string at HERE
- CLR -(PS) ; set vrefnum to 0 (path is specified)
- BRA.S load1
-
- doLoad:
- lea 40(a2),a0 ; Move the file name from PAD to HERE
- move.l a2,a1
- moveq #32,d0
- _blockmove
-
- ; CLR D0 ; Move the file name from PAD to HERE
- ; @0: MOVE.L 40(A2,D0.W),0(A2,D0.W) ;
- ; ADDQ #4,D0 ;
- ; CMP #32,D0 ;
- ; BLE.S @0
-
- load1: MOVE fsptr-base(BP),D0 ; get file stack pointer
- BMI.S @1 ; ... save the offset into text ...
- LEA fofsets-base(BP),A0 ; ... at fofsets+fspointer
- MOVE.L TextO-base(BP),0(A0,D0.W)
- LEA fends-base(BP),A0 ; TextE at fends+fspointer
- MOVE.L TextE-base(BP),0(A0,D0.W)
- @1: ADDQ #4,fsptr-base(BP) ; increment the file stack pointer
-
- MOVE.L #80,D0 ; create an 80 byte block for
- _NewPtr.CLEAR ; make the file control buffer
- MOVE.L A0,A4 ; save it for later
- MOVE.B #1,27(A0) ; set read only permission
- MOVE.L DP,18(A0) ; set name pointer
- MOVE (PS)+,22(A0) ; set vrefnum (working directory)
- _HOpen
- TST 16(A0)
- BNE.S derror
- _GetEOF ; get ...
- MOVE.L 28(A0),36(A0) ; ... and set ...
- MOVE.L 28(A0),-(PS) ; ... and hold the file size
-
- MOVE.L (PS),D0 ; set block size = file size
- _NewHandle
- BMI.S derror
-
- MOVE fsptr-base(BP),D0 ; get file stack pointer
- LEA fstack-base(BP),A1 ; file stack address
- MOVE.L A0,0(A1,D0.W) ; stash the handle at fstack+(fsptr)
- _HLock
-
- MOVE.L (A0),A0 ; get start addr of block
- MOVE.L A0,TextO-base(BP) ; set buffer start
- MOVE.L A0,D0 ; set buffer end ...
- ADD.L (PS)+,D0
- MOVE.L D0,TextE-base(BP) ; ... to start + size
-
- MOVE.L A4,A0 ; retrieve fcb pointer
- MOVE.L TextO-base(BP),32(A0) ; set read buffer addr in fcb
- _Read ; read data from file ...
- TST 16(A0) ; ... to scrap buffer
- BNE.S derror
- _Close
- _DisposPtr
- JMP go-base(BP) ; interpret scrap buffer
-
- DError: MOVE 16(A0),-(PS)
- _Close
- _DisposPtr
- JSR pquote-base(BP)
- DC.B 5,'Disk:' ; print the error messsage
- der: JSR dot-base(BP) ; report the error number
- der1: JMP huh-base(BP)
-
- ; DC.B 3,'REZ' ; Return the handle to a resource
- ; DC.W load-theLink ; ( ID type -- handle t or f )
- ; Rez: CLR.L -(SP)
- ; MOVE.L (PS)+,-(SP)
- ; MOVE (PS)+,-(SP)
- ; _GetResource
- ; MOVE.L (SP)+,D0 ; nil handle means error
- ; BEQ.S gser2
- ; MOVE.L D0,-(PS)
- ; MOVE #-1,-(PS)
- ; RTS
-
- DC.B 8,'?GE' ; "?GESTALT"
- DC.W load-theLink ; ( d.selector -- d.response true or false )
- QGestalt: ; false if 64K ROM or no _Gestalt or bad selector
- ; check for 64K ROM
- MOVE #$A86E,D0 ; _InitGraf
- _GetTrapAddress.newTool
- MOVE.L A0,D1
- MOVE #$AA6E,D0 ; _InitGraf AND $200
- _GetTrapAddress.newTool
- CMP.L A0,D1
- BEQ.S gser1 ; 64KROM
-
- ; Check for gestalt
- MOVE.W #$A89F,D0 ; _Unimplemented
- _GetTrapAddress.newTool ; NGetTrapAddress
- MOVE.L A0,D1
- MOVE.W #$A1AD,D0 ; _Gestalt
- _GetTrapAddress.newOS ; NGetTrapAddress
- CMP.L A0,D1
- BEQ.S gser1 ; no gestalt
-
- ; run gestalt
- MOVE.L (PS)+,D0
- _Gestalt
- BNE.S gser2
- MOVE.L A0,-(PS) ; return the result ... and ...
- MOVE #-1,-(PS) ; return true
- gsret: RTS
-
- gser1: ADDQ.L #4,PS ; gestalt error
- gser2: CLR -(PS) ; return false
- RTS
-
- DC.B 128+2,',S',0 ; ",S" compile a dnumber from ascii
- DC.W qgestalt-theLink ; NOTE: 1 and only 1 space seperates
- CommaS: MOVE.L A2,A0
- MOVEQ #4,D0
- @0: MOVE.B (IS)+,(A0)+
- DBRA D0,@0
- MOVE.L (A2),-(PS)
-
- TST.B fcolon-base(BP)
- BEQ.S gsret
- JMP dlit-base(BP)
-
- DC.B 64+9,'INT' ; "interpret"
- DC.W commas-theLink
- Interp: JMP main-base(BP)
- RTS ; <- gotta have this for mcompile
-
- DC.B 4,'ROO' ; "room" ( -- bytes )
- DC.W interp-theLink
- Room: MOVE.L A3,A0
- _RecoverHandle ; use handle rather than pointer
- _GetHandleSize
- MOVE.L A3,A0 ; Bottom
- ADDA.L D0,A0 ; + block size ...
- SUBA.L A2,A0 ; - end of dictionary
- MOVE A0,-(PS) ; = unused dictionary space
- RTS
-
- CSave: CLR -(SP) ; Room for which item number.
- MOVE #259,-(SP) ; Resource ID of ALRT
- CLR.L -(SP)
- _Alert ; About Item
- SUBQ #1,(SP)+ ; check which item dismissed.
- BEQ.S save ; save if 'ok'
- RTS
-
- DC.B 4,'SAV' ; "save" ( -- ) save the dictionary
- DC.W room-theLink
- Save: JSR here-base(BP)
- MOVE (PS)+,freePt-base(BP) ; save current DP
- MOVE Dict,DictPt-base(BP) ; save current DictPt
- BSR.S room
- MOVE (PS),freesz-base(BP) ; save current headroom
- BSR.S negate
- BSR.S grow ; reduce headroom to 4 bytes
- move.l a3,A0 ; bottom
- _RecoverHandle ; get DICT's handle
- CLR -(SP)
- MOVE.L A0,-(SP) ; push 2, 1 for each operation
- MOVE.L A0,-(SP)
- _ChangedResource
- _HomeResFile
- _UpdateResFile ; write out the DICT
- MOVE freesz-base(BP),-(PS)
- Grow: JSR here-base(BP)
- MOVE (PS)+,D1 ; hold rel DP in D1
- MOVE.L IS,-(PS)
- JSR torel-base(BP)
- MOVE (PS)+,D2
- MOVE.L (RS),-(PS)
- JSR torel-base(BP)
- JSR swapp-base(BP)
- MOVEA.L expand-base(BP),A0
- JMP (A0) ; JSR won't return here
-
- DC.B 4,'>AB' ; ">abs" (to-abs)
- DC.W save-theLink ; ( addr16 -- daddr32 )
- toAbs: CLR.L D0
- MOVE (PS)+,D0 ; pop rel addr
- LEA 0(BP,D0.W),A0 ; calc as offset to base ...
- MOVE.L A0,-(PS) ; ... and push
- RTS
-
- DC.B 64+6,'NEG' ; "negate" ( n -- -n )
- DC.W toabs-theLink
- negate: NEG (PS)
- RTS
-
- DC.B 5,'SPA' ; "space" ( -- ) emit a space
- DC.W negate-theLink
- space: MOVE.L #32,D0
- bra.s emitcode
-
- DC.B 4,'TYP' ; "type" ( rel.addr len -- )
- DC.W space-theLink ; emit len characters from rel.addr
- Type: MOVEM.L D3/D4,-(SP) ; don't trash registers!
- MOVE (PS)+,D3 ; get character count
- SUBQ #1,D3
- MOVE (PS)+,D4 ; get string relative address
- @0: MOVE.B 0(BP,D4.W),D0 ; get character byte
- bsr.s emitcode ; print character byte
- ADDQ #1,D4
- DBRA D3,@0
- MOVEM.L (SP)+,D3/D4 ; restore registers
- rts
-
- pQuote: ; runtime part of ."
- MOVE.L (RS),-(PS) ; push the addr of the string
- JSR torel-base(BP)
- ADDQ #1,(PS) ; skip the length byte
- MOVE.L (RS),A0
- CLR.L D0 ; clear the character count
- MOVE.B (A0),D0 ; get the length
- MOVE D0,-(PS) ; push it
- ADDQ #2,D0
- ANDI #$FFFE,D0 ; be sure its even
- ADD.L D0,(RS) ; skip over string upon return
- bra.s type ; type the string
-
- DC.B 4,'EMI' ; "emit" ( n -- ) send the ascii
- DC.W type-theLink ; to the terminal
- Emit: MOVE (PS)+,D0
- EmitCode: ; Emit contents of D0
- CMP.B #13,D0 ; is it a <cr>
- BEQ.S doCR
- CMP.B #8,D0 ; is it a <del>?
- BEQ.S doDEL
- ANDI #$FF,D0
- MOVE D0,-(A7)
- _DrawChar
- BSR.S penh
- MOVE WContRect+6-base(BP),D0 ; right coord of WContRect
- CMP D0,D1 ; is the position beyond the edge
- BLS.S emitr ; no
-
- doCR: PEA Scratch-base(BP)
- _GetPen
- MOVE Scratch-base(BP),D1
- MOVE WContRect+4-base(BP),D0 ; bottom coord of WContRect
- SUB #11,D0
- CMP D0,D1 ; is the position below the window
- BLS.S @0 ; no
-
- ; yes it is below the bottom of the window, so scroll up 11 pixels
- CLR.L -(A7) ; Make room for a region handle.
- _NewRgn ; get handle into (A7)
- PEA WContRect-base(BP) ; rect to scroll
- CLR -(A7) ; no horiz.
- MOVE #$FFF5,-(A7) ; 11 pix. vert.
- MOVE.L 8(A7),-(A7) ; push the region handle
- _ScrollRect
- _DisposRgn
-
- MOVE WContRect+4-base(BP),D1 ; bottom coord of WContRect
- SUBQ #4,D1
- BRA.S @1
-
- @0: ADD #11,D1 ; Add line height to pen location
- @1: MOVE #1,-(A7)
- MOVE D1,-(A7)
- _MoveTo
- emitr: RTS
-
- doDEL: BSR.S penh
- CMP #6,D1 ; first column?
- blt.s @0 ; don't beep anymore
- SUB #6,D1 ; back up
- MOVE D1,-(SP)
- MOVE Scratch-base(BP),-(SP)
- _MoveTo
- @0: RTS
-
- penh: PEA Scratch-base(BP)
- _GetPen
- MOVE Scratch+2-base(BP),D1
- RTS
-
- DC.B 6,'EXP' ; "expect" ( addr count -- )
- DC.W emit-theLink
- Expect: MOVEM.L D4/IS,-(SP)
- JSR swapp-base(BP) ; leave number of chars on stack
- MOVE (PS)+,D0 ; addr
- LEA 0(BP,D0.W),IS ; set IS to the input address
- CLR Counter
- MOVE (PS)+,D4
- @0: JSR key-base(BP)
- MOVE (PS)+,D5
- CMPI #CR,D5 ; if key = CR
- BNE.S @1
- MOVE.B #BL,0(IS,Counter)
- CLR.B 1(IS,Counter)
- MOVE.B #BL,2(IS,Counter)
- BRA.S @3
- @1: CMPI #BS,D5 ; if key = backspace
- BNE.S @2
- TST Counter ; do nothing if first key is BS
- BEQ.S @0
- SUBQ #1,Counter ; decriment counter
- bSR.s dodel ; -base(BP)
- JSR space-base(BP) ; ... rubout char
- bSR.s dodel ; -base(BP)
- BRA.S @0
- @2: MOVE.B D5,0(IS,Counter) ; stash the key into input buffer
- ADDQ #1,Counter
- MOVE D5,D0
- JSR emitcode-base(BP)
- CMP D4,Counter ; is count=number of chars to get?
- BNE.S @0
- @3: JSR docr-base(BP)
- MOVEM.L (SP)+,D4/IS
- RTS
-
- DC.B 64+1,'0',0,0 ; "0" ( -- 0 )
- DC.W expect-theLink
- Zero: CLR -(PS)
- RTS
-
- DC.B 64+4,'DRO' ; "drop" ( n -- )
- DC.W zero-theLink
- drop: ADDQ.L #2,PS
- RTS
-
- DC.B 4,'SWA' ; "swap" ( n1 n2 -- n2 n1 )
- DC.W drop-theLink
- swapp: MOVE.L (PS)+,D0
- SWAP D0
- MOVE.L D0,-(PS)
- RTS
-
- DC.B 64+5,'2DR' ; "2drop" ( d -- )
- DC.W swapp-theLink
- TwoDrop:
- ADDQ.L #4,PS
- RTS
-
- DC.B 4,'NUL' ; "null" ( -- )
- DC.W twodrop-theLink
- Null: RTS
-
- dc.b 4,'WAR' ; "warm" ( ? -- )
- dc.w null-theLink ; added 6/1/93
- WarmSt: jmp warm-base(bp)
-
- DC.B 6,'FOR' ; "forget" ( -- ) forgets dictionary
- DC.W warmst-theLink
- Forget: JSR tick-base(BP)
- MOVE (PS)+,D0
- MOVE -2(BP,D0.W),Dict
- LEA -6(BP,D0.W),DP
- RTS
-
- DC.B 8,'CON' ; "constant" compile: ( n16 -- )
- DC.W forget-theLink ; runtime: ( -- n16 )
- Const: JSR token-base(BP) ; make a header for the next token
- JSR header-base(BP)
- JSR marco-base(BP) ; to return a constant
- JSR literal-base(BP) ; compile time comma, runtime push
- MOVE #$4E75,(DP)+ ; compile rts
- RTS
-
- DC.B 6,'CRE' ; "create" compile: ( -- )
- DC.W const-theLink ; runtime: ( -- addr16 )
- Create: JSR token-base(BP) ; give token this runtime action:
- JSR header-base(BP)
- MOVE #$3D3C,(DP)+ ; • move #nnnn,-(ps)
- JSR here-base(BP)
- ADDQ #6,(PS)
- MOVE (PS)+,(DP)+ ; supply the nnnn from above
- MOVE #$4EEB,(DP)+ ; • jmp null-base(bp)
- MOVE.L DP,DoesAddr-base(BP) ; set DoesAddr to this "null"
- MOVE #null-base,(DP)+
- RTS
-
- DC.B 5,'DOE' ; "does>" ( -- ) (use after create)
- DC.W create-theLink ; set runtime action
- Does: MOVE.L (RS)+,D0 ; pop the return address
- SUB.L BP,D0 ; convert to rel.addr
- MOVE.L DoesAddr-base(BP),A0 ; load jmp d(bp) address from create
- MOVE D0,(A0) ; and stash rel.addr into it
- RTS ; returns same as ;
-
- DC.B 5,'ALL' ; "allot" ( n16 -- )
- DC.W does-theLink ; compiles nada into the dictionary
- Allot: ADDQ #1,(PS)
- ANDI #$FFFE,(PS) ; make it even!
- ADDA (PS)+,DP ; increment the dictionary pointer
- RTS
-
- DC.B 8,'VAR' ; "variable" compile: ( -- )
- DC.W allot-theLink ; runtime: ( -- addr16 )
- Variable:
- JSR token-base(BP) ; give token this runtime action:
- JSR header-base(BP)
- JSR marco-base(BP) ; Sun May 1, 1988 04:24:44
- MOVE #$3D3C,(DP)+ ; • move #nnnn,-(ps)
- JSR here-base(BP)
- ADDQ #4,(PS) ; calculate nnnn
- MOVE (PS)+,(DP)+ ; • (this is the nnnn)
- MOVE #$4E75,(DP)+ ; • rts
- ADDQ.L #2,DP ; 2 allot
- RTS
-
- DC.B 3,'AE:'
- DC.W variable-theLink
- aColon: MOVE #AEvents-base,-(PS)
- @0: JSR at-base(BP)
- ADDI #10,(PS)
- MOVE (PS),-(PS)
- JSR at-base(BP)
- TST (PS)+
- BNE.S @0
- MOVE (PS)+,D1
- MOVE.L A2,D0
- SUB.L BP,D0
- MOVE D0,0(BP,D1.W)
- MOVE.L (PS)+,(A2)+
- MOVE.L (PS)+,(A2)+
- LEA 4(A2),A0
- SUBA.L A3,A0
- MOVE A0,(A2)+
- CLR (A2)+
- MOVE #$4EBA,(A2)+
- MOVE #aepre-base,-(PS)
- JSR back-base(BP)
- JMP rbrack-base(BP)
-
- DC.B 128+3,';AE'
- DC.W acolon-theLink
- semiae: MOVE #$4EAB,(A2)+ ; • jsr aepost(bp)
- MOVE #aepost-base,(A2)+ ; • rts
- JMP semi-base(BP)
-
- DC.B 64+5,'>NA' ; ">name" ( 'addr -- name.addr )
- DC.W semiae-theLink
- toname: SUBQ #6,(PS)
- RTS
-
- DC.B 64+5,'>LI' ; ">link" ( 'addr -- link.addr )
- DC.W toname-theLink
- tolink: SUBQ #2,(PS)
- RTS
-
- DC.B 3,'ID.' ; "id." ( addr -- )
- DC.W tolink-theLink
- IDDot: JSR toname-base(BP)
- MOVEA.L DP,A0
- MOVEQ.L #5,D0
- @0: MOVE.L #$C9C9C9C9,(A0)+
- DBRA D0,@0
- MOVE (PS)+,D0
- MOVE.L 0(BP,D0.W),(DP)
- JSR here-base(BP)
- MOVE (PS),-(PS)
- JSR cat-base(BP)
- ANDI #$1F,(PS) ; look at 5 lsb's
- ADDQ #1,2(PS)
- JSR type-base(BP)
- JMP space-base(BP)
-
- DC.B 5,'WOR' ; "words" ( -- ) list words
- DC.W iddot-theLink
- Words: MOVE.L D3,-(SP) ; preserve register
- MOVE Dict,D3 ; start with the last word defined
- @0: MOVE D3,-(PS) ; push the name address
- ADDQ #6,(PS) ; get the CFA
- BSR.S iddot ; print the name
- MOVE 4(BP,D3.W),D3 ; put the next name addr into D3
- TST.B 1(BP,D3.W) ; Quit if name is 0
- BEQ.S @1 ; do next word if not=0
- JSR qterm-base(BP)
- TST (PS)+
- BEQ.S @0
- @1: MOVE.L (SP)+,D3 ; restore register
- RTS
-
- DC.B 3,'PAD' ; "pad" ( -- ) conversion pad
- DC.W words-theLink
- Pad: JSR here-base(BP)
- ADDI #40,(PS) ; pad is 40 bytes from HERE.
- RTS
-
- DC.B 4,'HOL' ; "hold" ( c -- ) place c at ...
- DC.W pad-theLink ; ... addr in Held.
- Hold: SUBQ #1,held-base(BP)
- MOVE held-base(BP),-(PS)
- JMP cstore-base(BP)
-
- DC.B 4,'SIG' ; "sign" ( sf dval -- dval )
- DC.W hold-theLink
- Sign: JSR rote-base(BP)
- TST (PS)+
- BGE.S @0
- MOVE #'-',-(PS)
- BSR.S hold
- @0: RTS
-
- DC.B 4,'DAB' ; "dabs" ( dval -- |dval| )
- DC.W sign-theLink
- Dabs: TST (PS)
- BGE.S @0
- JSR dneg-base(BP)
- @0: RTS
-
- DC.B 2,'<#',0 ; "<#" ( -- )
- DC.W dabs-theLink
- LSharp: BSR.S pad
- MOVE (PS)+,held-base(BP)
- MOVEA.L DP,A0
- MOVE #9,D0
- @0: CLR.L (A0)+
- DBRA D0,@0
- MOVE #30,-(PS)
- BRA.S hold
-
- DC.B 2,'#>'.0 ; "#>" ( dval -- addr len )
- DC.W lsharp-theLink
- SharpG: ADDQ.L #2,PS
- MOVE held-base(BP),(PS)
- BSR.S pad
- MOVE 2(PS),-(PS) ; over
- ADDQ #1,(PS)
- JMP minus-base(BP)
-
- DC.B 1,'#',0,0 ; "#" ( dval -- d/base )
- DC.W sharpg-theLink
- Sharp: MOVE NBase-base(BP),-(PS)
- JSR msmod-base(BP)
- JSR rote-base(BP)
- CMPI #9,(PS) ; is top of stack < 9?
- BLE.S @0
- ADDQ #7,(PS)
- @0: ADDI #48,(PS)
- JMP hold-base(BP)
-
- DC.B 2,'#S',0 ; "#s" ( dval -- 0 0 )
- DC.W sharp-theLink
- Sharps: BSR.S sharp
- TST.L (PS)
- BNE.S sharps
- RTS
-
- DC.B 2,'D.',0 ; "d." ( dval -- )
- DC.W sharps-theLink
- DDot: JSR swapp-base(BP)
- MOVE 2(PS),-(PS)
- JSR dabs-base(BP)
- BSR.S lsharp
- BSR.S sharps
- JSR sign-base(BP)
- BSR.S sharpg
- jsr type-base(BP)
- jmp space-base(bp)
-
- DC.B 2,'U.',0 ; "u." ( uval -- )
- DC.W ddot-theLink
- UDot: CLR -(PS)
- BRA.S ddot
-
- DC.B 3,'S>D' ; "s>d" ( n -- d )
- DC.W udot-theLink
- SToD: MOVE (PS),-(PS) ; dup
- JMP zerolt-base(BP) ; 0<
-
- DC.B 1,'.',0,0 ; "." ( n -- )
- DC.W stod-theLink
- Dot: BSR.S stod
- BRA.S ddot
-
- DC.B 130,'."',0 ; "."" ( -- ) compiler part of (.")
- DC.W dot-theLink
- dotQ: MOVE #pQuote-base,-(PS)
- JSR compile-base(BP) ; compile a call to (.")
- JSR here-base(BP) ; ( -- addr )
- MOVE #'"',-(PS) ; ( -- addr 34 )
- JSR word-base(BP) ; ( -- addr )
- JSR cat-base(BP) ; ( -- count )
- ADDQ #1,(PS) ; ( -- count+1 )
- JMP allot-base(BP) ; enclose the string in dictionary
-
- DC.B 129,'(',0,0 ; "(" ( -- ) begin comment
- DC.W dotq-theLink
- Comment CMPI.B #41,(IS)+ ; read in characters until ")"
- BNE.S Comment
- RTS
-
- DC.B 5,'CMO' ; "cmove" ( addr1 addr2 len -- )
- DC.W comment-theLink ; from figFORTH, fixed 8/3/91
- CMove: MOVE (PS)+,D0 ; D0 = length
- MOVE (PS)+,D1
- LEA 0(BP,D1.W),A1 ; A1 = addr2
- MOVE (PS)+,D1
- LEA 0(BP,D1.W),A0 ; A0 = addr1
- CMPA.L A0,A1
- BPL.S @2
-
- BRA.S @1 ; addr1 > addr2
- @0: MOVE.B (A0)+,(A1)+
- @1: DBRA D0,@0
- RTS
-
- @2: ADDA D0,A0 ; addr1 ≤ addr2
- ADDA D0,A1
- BRA.S @4
- @3: MOVE.B -(A0),-(A1)
- @4: DBRA D0,@3
- RTS
-
- DC.B 4,'FIL' ; "fill" ( addr count char -- )
- DC.W cmove-theLink
- Fill: MOVE (PS)+,D0 ; character
- MOVE (PS)+,D1 ; count
- SUBQ #1,D1 ; decrement count
- MOVE (PS)+,A0 ; relative addr
- LEA 0(BP,A0.W),A0 ; get absolute addr
- @0: MOVE.B D0,0(A0,D1.W) ; put char into addr + count
- DBRA D1,@0 ; decrement count & loop until 0
- RTS
-
- DC.B 9,'-TR' ; "-trailing"
- DC.W fill-theLink ; ( addr count -- addr new.count )
- dtrail: MOVE (PS)+,D1 ; get the count
- MOVE (PS),D0 ; get the rel.addr
- LEA 0(BP,D0.W),A0 ; get the abs.addr
- @0: CMPI.B #$20,-1(A0,D1.W) ; BEGIN is char at addr+count $20
- DBNE D1,@0 ; NOT UNTIL
- MOVE D1,-(PS) ; put new count on stack
- RTS
-
- DC.B 64+2,'1+',0 ; "1+" ( n -- n+1 )
- DC.W dtrail-theLink
- OnePl: ADDQ #1,(PS)
- RTS
-
- DC.B 64+2,'1-',0 ; "1-" ( n -- n-1 )
- DC.W onepl-theLink
- OneMi: SUBQ #1,(PS)
- RTS
-
- DC.B 64+2,'2+',0 ; "2+" ( n -- n+2 )
- DC.W onemi-theLink
- TwoPl: ADDQ #2,(PS)
- RTS
-
- DC.B 64+2,'2*',0 ; "2*" ( n -- n*2 )
- DC.W twopl-theLink
- ToStar: ASL (PS)
- RTS
-
- DC.B 64+2,'2/',0 ; "2/" ( n -- n/2 )
- DC.W tostar-theLink
- ToDiv: ASR (PS)
- RTS
-
- DC.B 5,'DEP' ; "depth" ( -- n )
- DC.W